#ifndef APPLICATION_BASE_HPP
#define APPLICATION_BASE_HPP

#include "core/timespan.hpp"
#include "metadata/variant.h"
#include "sdk_config.h"

class PI_API IApplication {
public:
    IApplication(int argc, const char **argv);

    virtual ~IApplication();

    void run();

    void quit();

protected:
    rttr::variant get_option(std::string_view key, rttr::variant def = {});

    virtual bool initialize() = 0;
    virtual void cleanup() = 0;
    virtual void update(pi_time_t delta, pi_time_t total) = 0;

    static IApplication *instance();

private:
    void install_crash_handlers();
};

#define PiApp() IApplication::instance()

#endif /* APPLICATION_BASE_HPP */
